InstancesΒΆ
In most of productions memory requirements are a major consideration. Large scene graphs containing a lot of nodes can benefit from using instancing to reduce memory costs. For example if you have a house that contains a lot of nodes, instead of duplicating the house many times to create a city, you can create instances of that house.
Creating an instance is done using the linker.
- Create a new scene graph node using the
Create/Create Node command. - Press the
SceneGraphNode > Instances > Edit button to open the Linker. - In the right column, select the nodes to instanciate.
Let's replace simple model instances by a complex, high resolution, instance of meshes. We want to keep the low resolution model for OpenGL and switch for a complex instance for the rendering.
- In any software, scatter low resolution models or transforms on a surface.
- You also need a group including the high resolution models.
- Hide the objects inside the high resolution group.
- Select all the low resolution objects.
- Press the
SceneGraphNode > Instances > Edit button to open the Linker. - Select in the right column all the children of the high resolution group. This will instanciate the high resolution models at every low resolution positions.
- Add a rule in the RenderGraph to hide the low resolution models. Check the
SceneGraphNode > Hidden attribute. - Add a rule in the RenderGraph to show the high resolution models. Uncheck the
SceneGraphNode > Hidden attribute.
- Make sure the instance root name end with a number, like this:
- Apply a
Attributes/RandomizeColor node in the DiffuseColor of your instances. - Choose a color and increase the different random parameters.
Thanks to the RenderGraph, Guerilla is able to override any attribute of a single instance.
- In the Rendergraph, drag'n drop the instance you want to override, or add a
RenderGraph/Path node and write the path to the specific high definition instance objects you'd like to override. Here it is^trees|tree609|leaf$ . - Override any attributes you like. Here we put the
Surface > Diffuse > Color to red.